/*
 * @Date: 2023-03-06 22:38:51
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2023-12-28 09:14:27
 * @Description: 登录模块api
 */
import Qs from 'Qs'
import axios from '@/utils/axios.request'
import type { loginType } from './types'

// 用户登录
const secretKey = 'thinkgem,jeesite,com'
export const userLogin = (params: loginType) => {
  params.username = params.username, secretKey
  params.password = params.password, secretKey
  return axios.post({
    url: '/a/login?__ajax=json',
    withCredentials: true,
    data: Qs.stringify({
      ...params
    })
  })
}

// 退出登录
export const userLoginout = () => {
  return axios.post({
    url: '/a/Logout',
    withCredentials: true,
    data: Qs.stringify({})
  })
}

/**
 * 获取系统可以用于缓存的数据
 */
export const initCache = () => {
  return axios.post({
    url: '/api/initCache',
    withCredentials: true,
    data: Qs.stringify({})
  })
}
